<?php
namespace app\miniprogram\validate;

use app\common\validate\Login as ParentLogin;

class Login extends ParentLogin
{
	/**
     * 验证规则
     */
    protected $rule = [
    	'code'            => 'require',
    	'encrypted_data'  => 'require',
    	'iv'              => 'require',
        'openid'          => 'require',
        'unionid'         => 'require',
        'spreadid'        => 'has:tyyh\\Spread,uid',
        'purePhoneNumber' => 'require:errmsg'
    ];
    /**
     * 提示消息
     */
    protected $message = [
    	'code.require'            => '请提交登录码',
    	'encrypted_data.require'  => '获取手机号解密信息失败',
    	'iv.require'              => '手机号获取信息不能为空',
        'openid.require'          => '获取用户信息失败,token可能过期需重新登录',
        'spreadid.has'            => '推广用户ID不存在',
        'unionid.require'         => '请先将小程序绑定微信公众平台',
    ];
    /**
     * 验证场景
     */
    protected $scene = [
    	'login'          => ['code'],
        'phone'          => ['encrypted_data', 'iv', 'openid', 'unionid', 'spreadid'],
        'get_token'      => ['openid', 'unionid'],
        'encrypted_data' => 'purePhoneNumber'
    ];
}